import Vue from 'vue'
import VueRouter from 'vue-router'

// 引入一级路由
import Index from '../pages/index.vue'
import Datail from '../pages/datail.vue'
import List from '../pages/list'
import Login from '../pages/login'
import Dizi from '../pages/dizi.vue'
import Xinjian from '../pages/xinjian.vue'
import Dingdan from '../pages/dingdan.vue'
import Zifu from '../pages/zifu.vue'

// 引入二级路由
import Cate from '../views/cate.vue'
import Cart from '../views/cart.vue'
import Home from '../views/home.vue'
import Mine from '../views/mine.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: '/index',
    component: Index,
    children: [
      {
        path: '/home',
        component: Home
      },
      {
        path: '/cate',
        component: Cate
      },
      {
        path: '/cart',
        component: Cart
      },
      {
        path: '/mine',
        component: Mine
      },
      {
        path: '',
        redirect: '/login'
      },
    ]
  },
  {
    path: '/datail',
    component: Datail
  },
  {
    path: '/list',
    component: List
  },
  {
    path: '/login',
    component: Login
  },
  {
    path: '*',
    redirect: '/index'
  },
  {
    path: '/dizi',
    component: Dizi
  },
  {
    path: '/xinjian',
    component: Xinjian
  },
  {
    path: '/dingdan',
    component: Dingdan
  },
  {
    path: '/zifu',
    component: Zifu
  },


]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
